<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js自带表单验证</title>
    <script type="application/javascript">
        function validForm() {
            var input = document.getElementById("i1");
            alert(input.checkValidity());
            alert(input.validationMessage);
        }
    </script>
</head>
<body>
<form>
    <input id="i1" type="text" min=10 max=50 required>
    <input type="button" name="验证" onclick="validForm()">
</form>
</body>
</html>